package com.group.zsxm.web.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.config.ParentPackage;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.group.core.Constants;
import com.group.core.common.Message;
import com.group.zsxm.entity.Xtuser;

import com.group.zsxm.service.common.SystemService;
import com.group.zsxm.web.common.BaseAction;
import com.opensymphony.xwork2.Action;
@ParentPackage("appDefault")
@Scope("prototype")
@Controller
@Results( { 
			@Result(name = "input", value = "/WEB-INF/jsp/sys/repass.jsp")
		})
public class SystemAction extends BaseAction{

	@Autowired
	@Qualifier("systemService")
	private SystemService systemService;
	
	private Xtuser xtuser ;
	private Map<String, String> map;
	public Xtuser getXtuser() {
		return xtuser;
	}
	public void setXtuser(Xtuser xtuser) {
		this.xtuser = xtuser;
	}
	public void onPrepare() {
		xtuser = (Xtuser)getSession().getAttribute(Constants.USER_SESSION_KEY);
	} 
	
	
	public Map<String, String> getMap() {
		return map;
	}
	public void setMap(Map<String, String> map) {
		this.map = map;
	}

	public String execute(){
		return Action.INPUT;
	}
	
	public void doSave(){
		Map<String, Object> mapOut = new HashMap<String, Object>();
		try{
			systemService.doUpdatePassWord(xtuser.getUserid(), map);
			message = new Message("1","保存成功");
		}catch(Exception e){
			message = new Message("-1",e.getMessage());
		}
		mapOut.put("message", message);
		this.renderJson(mapOut);
	}
}
